package com.wwwarehouse.resource_center.fragment.createobject.createtools;

import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.EditText;

import com.wwwarehouse.common.activity.base.BaseActivity;
import com.wwwarehouse.common.bean.response.CommonClass;
import com.wwwarehouse.resource_center.R;
import com.wwwarehouse.resource_center.customView.AutoClickButton;
import com.wwwarehouse.resource_center.eventbus_event.ToolTagEvent;
import com.wwwarehouse.resource_center.fragment.rules.TheParentFragment;

import de.greenrobot.event.EventBus;

/**
 * @author Joseph on 2017/9/15.
 *         <p/>
 *         添加标识标签
 */

public class ToolsTagFragment extends TheParentFragment {

    private AutoClickButton mBtn;
    private EditText mBarCode;      //条码,只限英文字母或数字，大于5，小余30

    @Override
    public void setTitle() {
        if (peekFragment() instanceof ToolsTagFragment)
            mActivity.setTitle(getString(R.string.add_tag_bar_));
    }

    @Override
    protected int getContentId() {
        return R.layout.fragment_add_tools_tag;
    }

    @Override
    protected void init(View view) {
        mBtn = findView(view, R.id.confirm_btn);
        mBarCode = findView(view, R.id.goods_bar_code);
        mBtn.bindEditText(mBarCode);
        Bundle bundle = getArguments();
        if (bundle != null) {
            if (!TextUtils.isEmpty(bundle.getString("barcode"))) {
                mBarCode.setText(bundle.getString("barcode"));
            }
        }


        mBtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                EventBus.getDefault().post(new ToolTagEvent(mBarCode.getText().toString()));
            }
        });
        ((BaseActivity) mActivity).hideSoftByEditViewIds(new int[]{R.id.set_rule_name, R.id.goods_sequence_code});

    }

    @Override
    public void onSuccess(CommonClass commonClass, int what) {

    }

    @Override
    protected void loadDatas() {
    }

    @Override
    public void onReLoad(int code) {

    }
}
